import request from '@neu/biz-core/utils/request'

export const pageByRelation = (relationId) => {
  const url = '/cmdb/relationinstances/relation/' + relationId + '/page'
  return (params) => {
    return request({
      url: url,
      params,
      method: 'get'
    })
  }
}

export const detail = (id) => {
  return request({
    url: '/cmdb/relationinstances/' + id,
    method: 'get'
  })
}

export const update = (id, data) => {
  return request({
    url: '/cmdb/relationinstances/' + id,
    data: data,
    method: 'put'
  })
}

export const upload = (relationId) => {
  return '/cmdb/relationinstances/relation/' + relationId + '/import'
}

export const remove = (id) => {
  return request({
    url: '/cmdb/relationinstances/batch',
    data: { ids: [id] },
    method: 'delete'
  })
}

export const batchRemove = (ids) => {
  return request({
    url: '/cmdb/relationinstances/batch',
    data: { ids },
    method: 'delete'
  })
}
